﻿Imports MetodosComuns
Imports extranet.BC
Imports extranet.BE

Partial Class Eventos_AdmEvtEditarPagina
    Inherits System.Web.UI.Page

    Protected Sub btnSalvar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSalvar.Click
        Try
            Dim objBETela As BETelaEvento
            objBETela = BCTelaEvento.SelecionarTela(lblIdPagina.Text)
            objBETela.Conteudo = FCKeditor1.Value
            BCTelaEvento.SalvarTela(objBETela.IdEvento, objBETela)

            System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
            System.Web.HttpContext.Current.Response.Write("alert(""Tela do Evento salvo com Sucesso!"")" & vbCrLf)
            System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
            Response.Redirect("AdmEvtGerenciamentoEvento.aspx?Evento=" & Request.QueryString("Evento"))
        Catch ex As ApplicationException
            System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
            System.Web.HttpContext.Current.Response.Write("alert(""Erro salvando a Tela do Evento: " & ex.Message & """)" & vbCrLf)
            System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
        End Try

    End Sub

    Protected Sub btnVoltar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnVoltar.Click
        Response.Redirect("AdmEvtGerenciamentoEvento.aspx?Evento=" & Request.QueryString("Evento"))
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        '==================       PROCEDIMENTO  PADRÃO  SEGURANÇA     =============================
        Dim objBESeguranca As BESeguranca
        Dim objBEUsuario As BEUsuario = Session("objBEUsuario")
        If IsNothing(objBEUsuario) Then Response.Redirect(TELA_LOGOUT)
        Session("strTela") = MetodosComuns.GetCurrentPageName()
        If Not IsPostBack Then          ' SEGURANÇA
            objBESeguranca = BCSeguranca.SelecionaPermissoes(objBEUsuario.GrupoAcesso, Session("strTela"))
            If Not objBESeguranca.Autorizado Then Response.Redirect(TELA_LOGOUT)
            Session("objBESeguranca") = objBESeguranca
        Else
            objBESeguranca = Session("objBESeguranca")
        End If

        If Not IsPostBack Then
            Dim objBETela As BETelaEvento
            lblIdPagina.Text = Request.QueryString("Tela")
            objBETela = BCTelaEvento.SelecionarTela(lblIdPagina.Text)
            lblNomePagina.Text = objBETela.Nome
            FCKeditor1.Value = objBETela.Conteudo
        End If
    End Sub
End Class
